package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 用户会员信息
 * 
 * @author ytche
 * @date 2017年4月22日
 * 
 */
@Entity
@Table(name = "tnb_customer_vip_info")
@JsonApiResource(type = "customerVipInfo")
public class CustomerVipInfo extends BaseEntity {

	private static final long serialVersionUID = 1L;
	private Customer customer;
	private String vipNum; // 会员编号
	private Dicttype level; // 会员等级
	private Integer active;// 活跃
	private Integer points;// 会员积分

	@JsonApiToOne
	@OneToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
	@JoinColumn(name = "customer_id", referencedColumnName = "id", unique = true)
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Column(name = "vip_num")
	public String getVipNum() {
		return vipNum;
	}

	public void setVipNum(String vipNum) {
		this.vipNum = vipNum;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "level", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getLevel() {
		return level;
	}

	public void setLevel(Dicttype level) {
		this.level = level;
	}

	@Column(name = "active")
	public Integer getActive() {
		return active;
	}

	public void setActive(Integer active) {
		this.active = active;
	}

	@Column(name = "points")
	public Integer getPoints() {
		return points;
	}

	public void setPoints(Integer points) {
		this.points = points;
	}

}
